home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-27 | 5.2 KB | 141 lines | [TEXT/CWIE] |
- //----------------------------------------------------------------------------
- // Filename: CSerialNumLib.h
- // Copyright © 1998 Wilfried Bernard. All rights reserved.
- //
- // See the file "McSerialNumber README" for more details and the licensing
- // agreement, etc.
- //
- // Description: Header to implement encoding/decoding of serial numbers
-
- // ATTENTION!
- // ----------
- // If you incorporate the 68k-library in your application
- // allways use the following switches for the Metrowerks IDE:
- // 68k Processor: check 4 Byte Ints and 8 Byte Doubles ON
- // check Far Data, Far Method Table and Far String Consts ON
- //
- // Send your questions/bugs and comments to:
- // <e-mail> mcwareusa@aol.com or mcwareusa@kagi.com
- // <www-page> http://members.aol.com/mcwareusa
- //
- //----------------------------------------------------------------------------
- // Revision History:
- // Mar, 28 1998 - 1.0 oSWSt first public release
- //----------------------------------------------------------------------------
-
- #pragma once
-
-
- class CSerialNumLib
- {
- public:
- // All Public Functions
-
- // MANIPULATOR
- //-------------
- //----------------------------------------------------------------------------
- // PARAMETER: ConstStr31Param first_name
- // ConstStr31Param last_name
- //
- // RESULT: long long test_number
- //
- // Entering the customer first and a last name creates a 64 bit test number
- // which is NOT the real serial number.
- // check with the real serialnumber AND your master code with CheckSumTest()
- //----------------------------------------------------------------------------
- static long long CalcNameCode (ConstStr31Param inFirstNameStr,
- ConstStr63Param inLastNameStr);
-
-
- //----------------------------------------------------------------------------
- // PARAMETER: long long test_number
- // long long serial_number
- // long long master_key
- //
- // RESULT: Boolean test_valid
- //
- // Checks validity of the real serialnumber by testing against your master code
- // and the names test number (CalcNameCode)
- //----------------------------------------------------------------------------
- static Boolean CheckSumTest (long long inNameCode,
- long long inSerialNumber,
- long long inMasterKey );
-
-
- //----------------------------------------------------------------------------
- // PARAMETER: ConstStr31Param serial_number_string
- // long long serial_number
- //
- // RESULT: Boolean test_valid
- //
- // Converts the serial number string into a real serialnumber,
- // strips all non-hexadecimal characters. Reports FALSE if serialnumber
- // string is invalid else TRUE
- //----------------------------------------------------------------------------
- static Boolean StripSerialNumber (ConstStr31Param inSerNrString,
- long long& outSum);
-
- // CONVERTER
- //-----------
- //----------------------------------------------------------------------------
- // PARAMETER: IN: StringPtr serial_number_string (p-string)
- // OUT: long long serial_number
- //
- // RESULT: none
- //
- // converts the serial number pascal-string into the 64 bit number,
- //----------------------------------------------------------------------------
- static void PStrToLLong (StringPtr inPStr,
- long long& outSum);
-
- //----------------------------------------------------------------------------
- // PARAMETER: IN: StringPtr serial_number_string (c-string)
- // OUT: long long serial_number
- //
- // RESULT: none
- //
- // Converts the serial number c-string into the 64 bit number,
- //----------------------------------------------------------------------------
- static void ANSIStrToLLong (char* inCStr,
- long long& outVal);
-
-
- //----------------------------------------------------------------------------
- // PARAMETER: OUT: ConstStr31Param serial_number_string (allocate memory!)
- // IN: long long IN serial_number
- //
- // RESULT: none
- //
- // Converts 64 bit number into a serial number pascal-string
- //----------------------------------------------------------------------------
- static void LLongToPStr (ConstStr31Param outPStr,
- long long inSum);
-
- //----------------------------------------------------------------------------
- // PARAMETER: OUT: ConstStr31Param serial_number_string (allocate memory!)
- // IN: long long serial_number
- //
- // RESULT: none
- //
- // Converts 64 bit number into a serial number c-string
- //----------------------------------------------------------------------------
- static void LLongToANSIStr (ConstStr31Param outCStr,
- long long inVal);
-
- //----------------------------------------------------------------------------
- // INPUT: long long IN master_key_number (if you pass <nil> an internal
- // check will take place)
- //
- // RESULT: long long OUT master_code
- //
- // returns the real master code number from the library
- //
- // ATTENTION:
- // First set your master code as default in the McSerialnumber application
- // preferences dialog BEFORE you create the library otherwise the resulting
- // mastercode may/can be zero (always test your library before implementation)
- //----------------------------------------------------------------------------
- static long long GetMasterCode (long long inMasterKey);
-
- };
-